<?php 
if(!isset($_SESSION)) 
	{ 
		session_start(); 
	}
if(!isset($_SESSION['db'])){
	$addressbrowser = $_SERVER['SERVER_NAME'];
	$temp = explode(".", $addressbrowser);
	$connection = mysql_connect("1.234.53.52", "cam", "5678" ) ;
	//$connection = mysql_connect("localhost", "root", "root" ) ;
	mysql_select_db("elihan", $connection);
	mysql_query("set names 'utf8'");
	$selectdatabase = mysql_query("SELECT am.DatabaseName,am.Logo from ac_eli_manager am where am.KeyName='$temp[0]' and am.`Status` = 2");
	$result = mysql_fetch_assoc($selectdatabase);

	$_SESSION['Logo']=$result['Logo'];
	$_SESSION['db']= $result['DatabaseName'];
	mysql_close($connection);
}
$database = $_SESSION['db'];
//include("handle/get_number_list.php");
/*$mysqli = new mysqli("1.234.53.52", "cam", "5678","$database");
//$mysqli = new mysqli("localhost", "root", "root","$database");
$query = mysqli_query($mysqli,"call getTotalDocument($id_employee)");
while($row = mysqli_fetch_array($query)){
	$num_re_pending = $row['RePendingDoc'];
	$num_re_not_approve = $row['ReNotApprovedDoc'];
	$num_re_approved= $row['ReApprovedDoc'];

	$num_meeting= $row['ReMeetingDoc'];
	$num_re_declined = $row['ReDeclinedDoc'];
	$num_re_reference_approved = $row['ReRefApprovedDoc'];
	$num_re_reference_waiting = $row['ReRefWaitingDoc'];
	$num_re_received_metting = $row['ReMeetingDoc'];


	$num_my_sendingDoc=$row['MySendingDoc'];
	$num_my_savedDoc=$row['MySavedDoc'];
	$num_my_approveDoc=$row['MyApproveDoc'];
	$num_my_declinedDoc=$row['MyDeclinedDoc'];
	$num_my_meetingDoc=$row['MyMeetingDoc'];

	$num_bin_re_doc = $row['BinReceiverDoc'];
	$num_bin_se_doc = $row['BinSendingDoc'];
}

$mysqli->close();*/

$project_query = mysql_query("SELECT p.IDProject, p.NameProject, p.Description, p.DateStart, p.DateComplete, p.IDManager, p.`Status`, e.FullName 
        	FROM pr_project p,employee e WHERE p.IDManager = e.IDEmployee ORDER BY p.IDProject ASC");
if (!$_SESSION['menuidadmin']) {
	$_SESSION['menuidadmin'] = array();
}
$menu_arraysadmin = $_SESSION['menuidadmin'];
$menu_priadmin = array_search( "pri",$menu_arraysadmin,true);
$menu_empadmin = array_search( "emp_",$menu_arraysadmin,true);
$menu_proadmin = array_search( "pro",$menu_arraysadmin,true);
?>
<script src="js/jquery.treeview.js" type="text/javascript"></script>
<script type="text/javascript">
	function menuEffect(ele){
		if($(ele).find('div:last').hasClass('collapsable-hitarea')){
			ajaxMenu('hide', $(ele).find('div:last').attr('id'));
			$(ele).find('div:last').removeClass('collapsable-hitarea');
			$(ele).find('div:last').addClass('expandable-hitarea');					
			$(ele).parent().find('ul:first').toggle();
		}else{
			ajaxMenu('show', $(ele).find('div:last').attr('id'));
			$(ele).find('div:last').removeClass('expandable-hitarea');
			$(ele).find('div:last').addClass('collapsable-hitarea');
			$(ele).parent().find('ul:first').toggle();
		}
	}
	
	function ajaxMenu(action,menuid){
		$.ajax({url:"ajax/ajaxmenuadmin.php", data : {actions : action , menuid : menuid}});
	}
		
</script>
<link rel="stylesheet" type="text/css" href="css/menu.css" />
<style>
* {
	font-family: verdana;
}

#fade { /*--Transparent background layer--*/
	display: none; /*--hidden by default--*/
	/*background: #000;*/
	position: fixed;
	left: 0;
	top: 0;
	width: 100%;
	height: 100%;
	opacity: .80;
	z-index: 9999;
}

.popup_block {
	display: none; /*--hidden by default--*/
	background: #fff;
	border: 1px solid silver;
	float: left;
	font-size: 1.2em;
	position: fixed;
	top: 50%;
	left: 50%;
	z-index: 99999;
	/*--CSS3 Box Shadows--*/
	/*--CSS3 Rounded Corners--*/
}

.btn_close {
	float: right;
	margin: 5px 5px 0 0;
	color: white;
	font-weight: bold;
}
/*--Making IE6 Understand Fixed Positioning--*/
* html #fade {
	position: absolute;
}

* html .popup_block {
	position: absolute;
}

.btnupbg {
	background: #309dcf;
	border-radius: 3px;
	color: white;
	cursor: pointer;
	font-weight: bold;
	height: 25px;
	padding: 0 5px 0;
	border-color: #C4C0B9;
	border-width: 1px;
	margin-right: 5px
}

.btnupbg:hover {
	background: #686868
}

.btnupload {
	background: -moz-linear-gradient(center top, #63B6DB, #309DCF) repeat;
}
</style>
<script>
$(document).ready(function(){
                                                                      
        //When you click on a link with class of poplight and the href starts with a # 
        $('a.poplight[href^=#]').click(function() {
                var popID = $(this).attr('rel'); //Get Popup Name
                var popURL = $(this).attr('href'); //Get Popup href to define size
                                
                //Pull Query & Variables from href URL
                var query= popURL.split('?');
                var dim= query[1].split('&');
                var popWidth = dim[0].split('=')[1]; //Gets the first query string value
 
                //Fade in the Popup and add close button
                $('#' + popID).fadeIn().css({ 'width': Number( popWidth ) }).prepend('<a href="#" class="close"><span class="btn_close">X</span></a>');
                
                //Define margin for center alignment (vertical + horizontal) - we add 80 to the height/width to accomodate for the padding + border width defined in the css
                var popMargTop = ($('#' + popID).height() + 80) / 2;
                var popMargLeft = ($('#' + popID).width() + 80) / 2;
                
                //Apply Margin to Popup
                $('#' + popID).css({ 
                        'margin-top' : -popMargTop,
                        'margin-left' : -popMargLeft
                });
                
                //Fade in Background
                $('body').append('<div id="fade"></div>'); //Add the fade layer to bottom of the body tag.
                $('#fade').css({'filter' : 'alpha(opacity=80)'}).fadeIn(); //Fade in the fade layer 
                
                return false;
        });
        
        
        //Close Popups and Fade Layer
        $('a.close, #fade, .iclose').live('click', function() { //When clicking on the close or fade layer...
                  $('#fade , .popup_block').fadeOut(function() {
                        $('#fade, a.close').remove();  
        }); //fade them both out
                
                return false;
        });
 
        
});
</script>
<div id="menuvar" style="width: 300px">
	<div id="sidetree">

		<ul id="tree" class="treeview">
			<li class="roots"><img src="images/icon_23_03.png" alt="" /><span> <a class="huyngo" style="color: white;font-weight: bold;"
					href="homeAdmin.php"><?=$l_home?> </a> </span></li>
					
			<li class="roots"><img src="images/index_39.png" alt="" /><span> <a class="huyngo" style="color: white;font-weight: bold;"
					href="companyprofileAdmin.php"><?=$l_menu_companyprofile?> </a>
			</span></li>
			<li class="roots" style="padding-top: 0 !important"><div style="padding:5px 0px 1px 0px" onclick="menuEffect(this)" onmouseover="this.style.cursor='pointer'" onmouseout="this.style.cursor='default'">
			<div style="width:200px"><img src="images/index_39.png" alt="" /><span><?=$l_menu_privateinfo?>
			</span></div><div id="pri" style="margin-top:-20px;" class="hitarea roots-hitarea <?php if ($menu_priadmin>-1){echo 'collapsable-hitarea';}else{echo 'expandable-hitarea'; }?>"></div>
			</div>
				<ul  style="display: <?php if ($menu_priadmin>-1){echo 'block';}else{echo 'none'; }?>">
					<li><img src="images/index_25.gif" alt="" /><a
						href="view-profile-admin.php"><?=$l_viewprofile?> </a>
					</li>
					<li class="last"><img src="images/index_25.gif" alt="" /><a href="history-logoff-admin.php"><?=$l_loginhistory?>
					</a>
					</li>
					<?php if($_SESSION['db']=='elitech'){?>
					<li class="last"><img src="images/index_25.gif" alt="" /><a href="ad_sa_salary.php?content=ad_sa_salary_management_content"><?=$l_quanly_luong;?>
					</a>
					</li>
					<?php }?>
				</ul>
			</li>
			<li class="roots" style="padding-top: 0 !important"><div style="padding:5px 0px 1px 0px" onclick="menuEffect(this)" onmouseover="this.style.cursor='pointer'" onmouseout="this.style.cursor='default'">
			<div style="width:200px"><img src="images/index_06.png" alt="" /><span><?=$l_menu_employee?>
			</span></div><div id="emp_" style="margin-top:-20px;" class="hitarea roots-hitarea <?php if ($menu_empadmin>-1){echo 'collapsable-hitarea';}else{echo 'expandable-hitarea'; }?>"></div>
			</div>
				<ul  style="display: <?php if ($menu_empadmin>-1){echo 'block';}else{echo 'none'; }?>">
					<li><img src="images/index_25.gif" alt="" /><a
						href="create-new-account-admin.php"><?=$l_createaccount?> </a>
					</li>
					<li><img src="images/index_25.gif" alt="" /><a href="employee-working-admin.php"><?=$l_employeeworking?>
					</a>
					</li>
					<li><img src="images/index_25.gif" alt="" /><a
						href="employee-broke-admin.php"><?=$l_employeebroke?> </a>
					</li>
					<li><img src="images/index_25.gif" alt="" /><a href="deparment-admin.php"><?=$l_departments?>
					</a>
					</li>
					<li><img src="images/index_25.gif" alt="" /><a
						href="document-admin.php"><?=$l_document?> </a>
					</li>
					<li><img src="images/index_25.gif" alt="" /><a href="general-notices-admin.php"><?=$l_generalnotice?>
					</a>
					</li>
					<li class="last"><img src="images/index_25.gif" alt="" /><a
						href="get-new-password-request-admin.php"><?=$l_newpasswordrequest?> </a>
					</li>

				</ul>
			</li>
			<li class="roots"><img src="images/index_39.png" alt="" /><span> <a class="huyngo" style="color: white;font-weight: bold;"
					href="private-memory-admin.php"><?=$l_menu_privatememo?> </a> </span>
			</li>
			<li class="roots" style="padding-top: 0 !important"><div style="padding:5px 0px 1px 0px" onclick="menuEffect(this)" onmouseover="this.style.cursor='pointer'" onmouseout="this.style.cursor='default'">
			<div style="width:200px"><img src="images/index_43.png" alt="" /><span><?=$l_project?>
			</span></div><div id="pro" style="margin-top:-20px;" class="hitarea roots-hitarea <?php if ($menu_proadmin>-1){echo 'collapsable-hitarea';}else{echo 'expandable-hitarea'; }?>"></div>
			</div>
			<ul  style="display: <?php if ($menu_proadmin>-1){echo 'block';}else{echo 'none'; }?>">
					<li><img src="images/index_25.gif" alt="" /><a href="project_admin.php?content=admin/project/list_project.php"><span><?php echo $l_project_home;?></span></a>
					
					</li>
					<li><img src="images/index_25.gif" alt="" /><a href="project_admin.php?content=admin/project/newproject.php"><span><?php echo $l_project_new;?></span></a>
					
					</li>
					<li class="last"><img src="images/index_25.gif" alt="" /><span><?php echo $l_projectlist;?></span>
						<ul>
					<?php while ($row=mysql_fetch_array($project_query)){ 
						$idproject = $row[IDProject];
						$nameproject =$row[NameProject];
						?>
						
							<li>
								<span><img src="images/index_25.gif" alt="" /><a href="admin/project/changeproject.php?id=<?=$idproject?>"><?=$nameproject?></a> </span>
							</li>
						
						<?php }?>
						</ul>
					</li>


				</ul>
			</li>
			<li style="display: none;"/>

		</ul>
	</div>
</div>
